<?php

namespace Sharks\Core\Support\Log;

/**
 * 日志
 */
class Log {

    private static $loggers = null;

    public static function register($logger) {
        if (is_null(self::$loggers)) {
            self::$loggers = array();
        }
        self::$loggers[] = $logger;
    }

    public static function debug($msg) {
        if (is_null(self::$loggers)) {
            return;
        }
        foreach (self::$loggers as $logger) {
            $logger->debug($msg);
        }
    }

    public static function info($msg) {
        if (is_null(self::$loggers)) {
            return;
        }
        foreach (self::$loggers as $logger) {
            $logger->info($msg);
        }
    }

    public static function warning($msg) {
        if (is_null(self::$loggers)) {
            return;
        }
        foreach (self::$loggers as $logger) {
            $logger->warning($msg);
        }
    }

    public static function error($msg) {
        if (is_null(self::$loggers)) {
            return;
        }
        foreach (self::$loggers as $logger) {
            $logger->error($msg);
        }
    }

    public static function critical($msg) {
        if (is_null(self::$loggers)) {
            return;
        }
        foreach (self::$loggers as $logger) {
            $logger->critical($msg);
        }
    }

    public static function alter($msg) {
        if (is_null(self::$loggers)) {
            return;
        }
        foreach (self::$loggers as $logger) {
            $logger->alter($msg);
        }
    }
}